<?php
/** $Id: default_form.php 11917 2009-05-29 19:37:05Z ian $ */
defined( '_JEXEC' ) or die( 'Restricted access' );
	$user = JFactory::getUser();
?>
 <div class="task-detail" id="printpageview">
  <span id="printheader"></span>
  <h2 class="task-title">ID. <?php echo $this->row->id;?> <?php echo $this->row->title;?></h2>
  <p class="date">(Oprettet d. <?php echo JHtml::_('date', $this->row->created , JText::_('DATE_FORMAT_LC6')) ;?>, <?php if($this->row->usertype==1) { echo "Erhverv"; }  else { echo "Privat"; }?> Kunde)</p>
<div class="content-view">
    <p class="desc"><?php echo $this->row->description;?></p>
    <p class="kunde-info">
    	 Kunden estimerer prisen til at være: <?php echo $this->row_pris->title; ?>
        <br>
         Opgaven ønskes afsluttet: <?php echo JHtml::_('date', $this->row->deadline , JText::_('DATE_FORMAT_LC6')) ;?><br>
         Landsdel: <?php echo $this->land; ?>
    </p>
    <?php												
		$status = $user->guest;
		
		
		
		if($status == 1){
		//do user logged out stuff
		?>
		 <p class="kunde-info"><big>Du skal være logget på for at se kundens kontaktoplysninger.</big></p>
            <div class="link-btn">
                <a class="button fll" href="index.php?option=com_users">Log på</a>
                <a class="button fll" href="index.php?option=com_jobs">Tilmeld malerfirma</a>
            </div>
		<?php
		}
		else
		{
			
			$db =& JFactory::getDBO();
			$query = 'SELECT count(*) as "viewjobtotal" FROM #__uworks where userid = '.$user->id.' and jobid='.$this->row->id;
			
			$db->setQuery( $query );
			$viewjob = $db->loadObject();
			if((isset($viewjob) && $viewjob->viewjobtotal >0) || isset($user->groups[8]) ) {
			
		//do user logged in stuff
		?>
        <p class="kunde-info">Kundens kontaktoplysninger:</p>
		 <div class="contact-info">
			<div class="left-col fll">
            	<?php if($this->row->usertype==1) { ?>
            	<p><?php echo $this->row->company;?></p>
                <?php } ?>
				<p><?php echo $this->row->firstname;?> <?php echo $this->row->lastname;?>
                	<br><?php echo $this->row->address;?>
                <br/>
                <?php echo $this->row->postcode;?> <?php echo $this->row->city;?> <?php echo $this->land;?>
                </p>
				
				<p>Email: <?php echo $this->row->email;?>
                	<br/>Tlf.: <?php echo $this->row->telephone;?>
                </p>
			</div>
			<div class="right-col fll">
		        <?php if($this->row->workataddress==0) { ?>
				<p>Arbejdet udføres på følgende adresse:
                <br/><?php echo $this->row->address1;?>
                <br/><?php echo $this->row->postcode1;?> <?php echo $this->row->city1 ;?> <?php echo $this->land1;?>
                </p>
				
                <?php } ?>
                 <?php
					$file01 = $this->row->fileurl1;
					$file02 = $this->row->fileurl2;
					$file03 = $this->row->fileurl3;
			
			
				if(strlen($file01) > 0) {
					$lfile01 = '<a target="_blank" href="'.JURI::root().$file01.'">'.$file01.'</a>';
					
				} else {
					$lfile01 = '';
				}
				if(strlen($file02) > 0) {
					$lfile02 = '<a target="_blank"  href="'.JURI::root().$file02.'">'.$file02.'</a>';
					
				} else {
					$lfile02 = '';
				}
				if(strlen($file03) > 0) {
					$lfile03 = '<a target="_blank"  href="'.JURI::root().$file03.'">'.$file03.'</a>';
				
				} else {
					$lfile03 = '';
				}
				
            ?>
            <p><?php echo $lfile01;?>
                <br/><?php echo $lfile02;?>
                <br/><?php echo $lfile03;?>
            </p>
            
			 </div>
            
		</div>
       
        <div class="print">
        <a class="button print-btn" href="javascript:if(window.print) printPage()"><span>Udskriv</span></a>
        		<script>
        		function printPage()
                {
                   var html="<html>";
				    html+='<link rel="stylesheet" type="text/css" media="screen" href="templates/3dmaler/css/styles.css" />';
				   var tmp = $("#printpageview .print").html();
				   $("#printpageview .print").html('');
				   $("#printheader").html('<img src="templates/3dmaler/img/email_logo_footer.jpg"></img>');
				   html+= "<div id='printpage'>";
				   
				   html+=$("#printpageview").html();
                   //html+= document.getElementById('printpageview').innerHTML;
				   html+= "</div>";
                   html+="</html>";
				   $("#printheader").html('');
                   $("#printpageview .print").html(tmp);
				   var printWin = window.open();
                   //var printWin = window.open('','','left=0,top=0,width=800,height=1,toolbar=0,scrollbars=0,status=0');
                   printWin.document.write(html);
                   printWin.document.close();
                   printWin.focus();
				   
                   printWin.print();
				   
                   printWin.close();
				   
                }
				</script>
    	</div>
        <?php } ?>
		<?php
		} 
	?>
   
    
    
 </div>
  </div>